package com.wu.family.utils.img;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import android.graphics.Bitmap;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;


public class BitmapMgrImpl2 extends AbsBitmapMgr2{
	private static BitmapMgrImpl2 instance = null;
	private ExecutorService executorService = Executors.newFixedThreadPool(5);
	private ExecutorService executorServiceNet = Executors.newFixedThreadPool(8);
	
	private BitmapMgrImpl2(){}
	
	public static BitmapMgrImpl2 getInstance()
	{
		if (instance == null) {
			instance = new BitmapMgrImpl2();
		}
		return instance;
	}
	
	@Override
	public void findLocalBackground(Runnable runnable) {
		executorService.submit(runnable);
		
	}
	@Override
	public void netLoadBackground(Runnable runnable) {
		executorServiceNet.submit(runnable);
	}
	
	public ImageCallBack feedCallBack = new ImageCallBack() {
		
		@Override
		public void setImage(Bitmap bmp, String url, ImageView view) {
			if(url.equals((String)view.getTag())) {
				view.setScaleType(ScaleType.CENTER_CROP);
				view.setImageBitmap(bmp);
			}
		}
	};
}
